package appp;

public class Appp {

    public static void main(String[] args) {
        System.out.println(check("<{<>[]}>"));
    }

    public static boolean check(String str) {
        boolean result = true;
        Stack s = new Stack();

        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '[' || str.charAt(i) == '{' || str.charAt(i) == '<') {
                s.push(str.charAt(i));
            } else if (str.charAt(i) == '}' && !s.pop().equals('{')) {
                result = false;
            } else if (str.charAt(i) == ']' && !s.pop().equals('[')) {
                result = false;
            } else if (str.charAt(i) == '>' && !s.pop().equals('<')) {
                result = false;
            }
            
        }
        if (s.hasNext()) result = false;
        return result;
    }
}
